package com.tech.zhidengxian.controller;

import com.alibaba.fastjson.JSON;
import com.tech.zhidengxian.model.constant.District;
import com.tech.zhidengxian.model.dto.ReceiverAddressDTO;
import com.tech.zhidengxian.model.dto.result.ReturnResult;
import com.tech.zhidengxian.model.dto.result.ReturnResultUtils;
import com.tech.zhidengxian.service.api.ReceiverAddressService;
import com.tech.zhidengxian.service.impl.ReceiverAddressServiceImpl;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/receiverAddress")
public class ReceiverAddressController {
    @Resource
    private ReceiverAddressService addressService;
    @RequestMapping("/queryAddressListByUid")
    public ReturnResult<List<ReceiverAddressDTO>> queryAddress(Long uid){
        return ReturnResultUtils.returnSuccess(addressService.queryAddressListByUid(uid));
    }

    @RequestMapping("/queryUserDefAddress")
    public ReturnResult<ReceiverAddressDTO> queryUserDefAddress(Long uid){
        return ReturnResultUtils.returnSuccess(addressService.queryUserDefAddress(uid));
    }



    @RequestMapping("/updateAddress")
    public ReturnResult<ReceiverAddressDTO> updateAddress(@RequestBody ReceiverAddressDTO receiverAddressDTO){
        return ReturnResultUtils.returnSuccess(addressService.updateById(receiverAddressDTO));
    }
    @RequestMapping("/insertAddress")
    public ReturnResult<ReceiverAddressDTO> insertAddress(@RequestBody ReceiverAddressDTO receiverAddressDTO){
        return ReturnResultUtils.returnSuccess(addressService.insert(receiverAddressDTO));
    }
}
